# -*- coding: utf-8 -*-
# 单据信息操作相关路由
import core.order as order
from flask import jsonify, request
import core.init.initconfig.tableConfig as tableConfig


def get_retailcolumns():
    '''
    获取零售单表头
    :return:
    '''
    response = tableConfig.get_tablecolumns('retailProducts')
    return response


def get_searchproducts(**kwargs):
    '''
    商品录入接口
    :param kwargs:参数格式JSON格式
    :return:
    '''
    order_obj = order.Retail()
    param = request.get_json(True)
    response = order_obj.SearchProducts(param)
    return response


def get_productpic(**kwargs):
    '''
    商品详细信息里的图片查询接口
    :return:
    '''
    order_obj = order.Retail()
    param = request.get_json(True)
    pro = param["product"]
    response = order_obj.get_productpic(pro)
    return response


def deletepros(**kwargs):
    '''
    删除商品接口
    :param kwargs:
    :return:
    '''
    order_obj = order.Retail()
    param = request.get_json(True)
    pro = param["lineno"]
    response = order_obj.delete_pro(pro)
    return response


def updatepros_qty(**kwargs):
    '''
    修改商品数量
    :param kwargs:
    :return:
    '''
    order_obj = order.Retail()
    param = request.get_json(True)
    pro = param["product"]
    response = order_obj.update_qty(pro)
    return response


def updatepros_pricelist(**kwargs):
    '''
    修改商品价格
    :param kwargs:
    :return:
    '''
    order_obj = order.Retail()
    param = request.get_json(True)
    pro = param["product"]
    response = order_obj.update_pricelist(pro)
    return response


def update_saler(**kwargs):
    '''
    修改商品行营业员
    :param kwargs:
    :return:
    '''
    order_obj = order.Retail()
    param = request.get_json(True)
    response = order_obj.update_saler(param)
    return response


def initorder():
    '''
    开新单
    :return:新单信息
    '''
    return order.initOrder()
